package khiem.java.sample.genericgrapth;

public class TestGraph {
  
  public static void main(String args[]) {
    // builds graph
    GenericGraph<GraphNode> graph = new GenericGraph<GraphNode>();
    GraphNode a = new GraphNode("a", "2.0.0");
    GraphNode b = new GraphNode("b", "2.0.1");
    GraphNode c = new GraphNode("c", "3.1.1");
    GraphNode d31 = new GraphNode("d", "3.1.0");
    GraphNode d32 = new GraphNode("d", "3.2.0");
    GraphNode d33 = new GraphNode("d", "3.3.0");
    GraphNode d34 = new GraphNode("d", "3.4.0");
    GraphNode d35 = new GraphNode("d", "3.5.0");
    GraphNode e = new GraphNode("e", "5.3.0");
    GraphNode f15 = new GraphNode("f", "1.5.0");
    GraphNode f17 = new GraphNode("f", "1.7.0");
    GraphNode h23 = new GraphNode("h", "2.3.1");
    GraphNode h22 = new GraphNode("h", "2.2.1");
    
    a.addDependency("b", ">=", "2.0.0");
    a.addDependency("c", ">=", "3.0.0");
    a.addDependency("h", ">=", "2.0.0");
    b.addDependency("d", ">=", "3.2.0", "<=", "4.0.0");
    c.addDependency("d", ">=", "3.0.0", "<=", "3.4.0");
    d31.addDependency("e", ">=", "5.0.0");
    d32.addDependency("e", ">=", "5.1.0");
    d33.addDependency("e", ">=", "5.7.0");
    d34.addDependency("f", ">=", "1.0.0");
    d35.addDependency("f", ">=", "1.0.0");
    f17.addDependency("g", ">=", "2.0.0");
    h22.addDependency("f", ">=", "1.0");
    h23.addDependency("f", ">=", "1.6");
    //e.addDependency("b", ">=", "2.0.0");
    
    graph.addAll(a, b, c, d31, d32, d33, d34, d35, e, f15, f17, h23, h22);
    
    // add some installed nodes
    
    GraphNode f13 = new GraphNode("f", "1.3.0");
    GraphNode b10 = new GraphNode("b", "1.0.0");
    GraphNode d21 = new GraphNode("d", "2.1.0");
    GraphNode z = new GraphNode("z", "1.0.0");
    b10.addDependency("d", ">=", "2.0");
    z.addDependency("d", ">=", "3.5");
    
    graph.addInstalledNodes(f13, b10, d21, z);
    
    // try resolving
    DependencyResolver_<GraphNode> resolver = new DependencyResolver_<GraphNode>(graph);
    resolver.resolve(a);
  }
}
